import { useEffect, useState } from "react";
import reactLogo from "./assets/react.svg";
import viteLogo from "/vite.svg";
import "./App.css";
import "./i18n";
import { useLang, setLanguage, getLanguage } from "./i18n-use";

function App() {
  let [count, setCount] = useState(0);
  const locales = useLang(["test", "home"]);
  const locales1 = useLang(["test"]);
  useEffect(() => {
    //console.log(locales);
    //console.log(locales1);
    console.log(getLanguage());
  }, [count]);
  return (
    <>
      <h1>Vite + React</h1>
      <span
        onClick={() => {
          setLanguage(locales.defaultLocale == "zh" ? "in" : "zh");
          //console.log(222222222);
          //setLanguage(getLanguage() == "zh" ? "en" : "zh");
          //updateLocale(["test", "home"]);
          //console.log(getLanguage());
          //console.log(t("姓名"));
          setCount((count += 1));
          //window.location.reload();
        }}
      >
        切换语言{locales.t("姓名")}
      </span>
      <p>
        {locales.t("年龄{age}", {
          age: 18,
        })}
      </p>
      <p>{locales.t("asda")}sad</p>
    </>
  );
}

export default App;
